<template>
  <div id="area-info">
    <main-content :edit-component-name="editComponentName" :name="name" :table-head="tableHead"
                  :query-condition="queryCondition" :is-tree-table="isTreeTable" :buttons="buttons"></main-content>
  </div>
</template>

<script>
  import {mapState} from 'vuex'
  import mainContent from '../../../common/main-content'

  export default {
    computed: {
      ...mapState({
        buttons: state => state.manager.buttons
      })
    },
    components: {
      mainContent
    },
    name: "area-info",
    mounted() {
      this.initQueryCondition()
    },
    methods: {
      initQueryCondition() {
        this.$set(this.queryCondition[2], 'url', this.buttons.target)
        this.$set(this.queryCondition[2], 'permission', this.buttons.id)
        this.$set(this.queryCondition[3],'url',this.buttons.children[0].children[0].target)
        this.$set(this.queryCondition[3],'permission',this.buttons.children[0].children[0].id)
      }
    },
    data() {
      return {
        name: '地区',
        isTreeTable: true,
        editComponentName: 'area-edit',
        queryCondition: [
          {
            name: '地区名称',
            key: 'name',
            type: 'input'
          },
          {
            name: '地区编号',
            key: 'code',
            type: 'input'
          },
          {
            name: '上级地区',
            key: 'parentId',
            type: 'union-select'
          },
          {
            name: '地区类型',
            key: 'areaTypeId',
            type: 'union-select',
            initValue: 'winfo_bdd00dbcc2deb411e9b6c954e1add85a5d'
          }
        ],
        tableHead: [
          {
            key: 'name',
            name: '地区名称',
            type: 'text'
          }, {
            key: 'parentName',
            name: '上级地区',
            type: 'text'
          }, {
            key: 'code',
            name: '地区编号',
            type: 'text'
          }, {
            key: 'areaType',
            name: '地区类型',
            type: 'text'
          }, {
            key: 'areaTypeCode',
            name: '地区类型编号',
            type: 'text'
          }
        ],
      }
    },
  }
</script>

<style scoped>

</style>
